﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<base href="<%=basePath%>">
<!-- jsp文件头和头部 -->
<%@ include file="../system/admin/top.jsp"%>
<script type="text/javascript" src="static/js/layer.js"></script>
<link rel="stylesheet" href="static/css/layui.css"  media="all">
<link href="static/css/bootstrap.min.css" rel="stylesheet" />
<link href="static/css/bootstrap-responsive.min.css" rel="stylesheet" />
<link rel="stylesheet" href="static/css/font-awesome.min.css" />
<link rel="stylesheet" href="static/css/chosen.css" />
<link rel="stylesheet" href="static/css/ace.min.css" />
<link rel="stylesheet" href="static/css/ace-responsive.min.css" />
<link rel="stylesheet" href="static/css/ace-skins.min.css" />
<link rel="stylesheet" href="static/css/bootstrap-datetimepicker.min.css" /><!-- 日期框 -->
<!-- 表单校验 -->
<script type="text/javascript" src="plugins/jquery-validation/jquery.validate.js"></script>
<script type="text/javascript" src="static/js/layer.js"></script>
<link rel="stylesheet" href="static/css/layui.css" media="all">
<script type="text/javascript">
$(function() {
	//日期框
	
	 $('#datetimepicker').datetimepicker({
       language: 'zh-CN',//显示中文
       format: 'yyyy-mm-dd hh:ii:ss',//显示格式
       startDate: new Date(),//初始化当前日期
       autoclose: true,//选中自动关闭
       todayBtn: true//显示今日按钮
	});

   // $('#datetimepicker').datetimepicker('update');
	
	$("#createContract").click(function(){
		layer.confirm('确定申请吗?', {
			  btn: ['确定','取消'] //按钮
			}, function(){
				var content=$("#reduInfo").val().replace(/\n/g,"<br/>");
				$("#reduInfo").val(content);
				$.post("<%=basePath%>faxijianmian/faxijianmianApplyAudit.do",$("#Form").serialize(),function(backdata){
					if (backdata.success) {
						//如果提交成功就关闭弹窗
						closeAply();
					}else{
						layer.alert(backdata.msg);
					}
				})
			}, function(){
			 
			});
	})
	//JS校验罚息减免金额小于累计罚息金额
	 $("#reduOverdueFee").blur(function(){
		//获取表单数据
		var reduOverdueFee = $(this).val();
		var overdueFee = parseFloat($("#receiveMoney").html());
		var re =/^\d+(\.\d{1,2})?$/;
  	    if(!re.test(reduOverdueFee)){
  	    	layer.alert("请输入正确的罚息金额!");
      	  return;
  	    }
		if (reduOverdueFee > overdueFee || reduOverdueFee <= 0) {
			layer.alert("请输入正确的罚息金额!");
		}
	}) 
	 $("#Form").validate({
		rules:{
			reduDay:{
				required:true
			},
			reduInfo:{
				required:true,
				rangelength:[1,200],
			}
		},
		messages:{
			reduDay:{
				required:"有效期必须填"
			},
			reduInfo:{
				required:"减免说明必须填",
				rangelength:"减免说明长度为{0}~{1}",
			}
		},
		errorClass: "red"
	});  
	
})
function closeAply(){
	 var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
     parent.layer.close(index);
}
</script>
</head>
<body>
		
	<div style="width: 80%; margin: 0 50px;">
		<br>
		<form action="<%=basePath%>faxijianmian/faxijianmianApplyAudit.do" name="Form" id="Form" method="post">
			<input type="hidden" name="callLoanNid" id="id" value="${info.callLoanNid}" />
		<table class="table table-bordered">
			<tr>
				<td>借款产品：</td><td id="productName">${info.productName}</td>
				<td>催收编号：</td><td id="callLoanNid">${info.callLoanNid}</td>
				<td>未还罚息金额：</td><td id="overdueFee">${info.overdueFee}</td>
			</tr>
			<tr>
				<td>借款人：</td><td id="realName">${info.realName}</td>
				<td>身份证号：</td><td id="contIdCard">${info.contIdCard}</td>
				<td>逾期天数：</td><td id="overdueDate">${info.overdueDate}</td>
			</tr>
		</table>
		<table>	
			<tr>
				<td>罚息减免金额：</td>
				<td>
					<div class="form-group">
						<input type="text" class="form-control" id="reduOverdueFee" placeholder="保留两位小数" name="reduOverdueFee">&emsp;元
						<span style="color: red">&emsp;可减免罚息金额:
							<span id="receiveMoney">${receiveMoney}</span>
						</span>
					</div>
				</td>
				<td></td>
				<td colspan="4"></td>
			</tr>
			<tr>
				<td>有效期：</td>
				<td>
					<input style="width:48%;" class="span10" name="reduDay" type="text" value="${reduDay}" readonly="readonly" />
				</td>
				<td colspan="4"></td>
			</tr>
			
			<tr>
				<td>减免说明：</td>
				<td><textarea id="reduInfo" name="reduInfo" class="form-control" rows="5"
						style="width: 440px;height: 150px"></textarea></td>
				<td colspan="4"></td>
			</tr>
		</table>
			<br>
			<button id="createContract" type="button" class="btn btn-primary">确定申请</button>
			<button type="button" class="btn btn-default" data-dismiss="modal" onclick="closeAply()">关闭</button>
		</form>
	</div>
	
		<!-- 引入 -->

		<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
		<script src="static/js/bootstrap.min.js"></script>
		<script src="static/js/ace-elements.min.js"></script>
		<script src="static/js/ace.min.js"></script>
		<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script><!-- 单选框 -->
		<script type="text/javascript" src="static/js/bootstrap-datepicker.min.js"></script><!-- 日期框 -->
		<script type="text/javascript" src="static/js/bootstrap-datetimepicker.js"></script><!-- 日期框 -->
		<script type="text/javascript" src="static/js/bootstrap-datetimepicker.zh-CN.js"></script><!-- 日期框 -->
		<script type="text/javascript" src="static/js/locales/bootstrap-datetimepicker.fr.js"></script><!-- 日期框 -->
		<!-- 编辑框-->
		<script type="text/javascript" charset="utf-8">window.UEDITOR_HOME_URL = "<%=path%>/plugins/ueditor/";</script>
		<script type="text/javascript" charset="utf-8" src="plugins/ueditor/ueditor.config.js"></script>
		<script type="text/javascript" charset="utf-8" src="plugins/ueditor/ueditor.all.js"></script>
		
		
		
		
		<!-- 编辑框-->
		<script type="text/javascript">
		$(top.hangge());
		function reurl(){ 
			UE.getEditor('content');
			} 
		setTimeout('reurl()',500);
		</script>
</body>
</html>
